/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */


/*
ID: ivan.ca2
LANG: JAVA
TASK: beads
*/
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;


class beads {

    public beads() {
    }

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        java.util.Scanner in = null;
        java.io.PrintWriter out = null;
        try {
            // TODO code application logic here


            in = new java.util.Scanner(new java.io.FileReader("beads.in"));
            int cantPepas = in.nextInt();
            int canMayor = 0;
            int pc=0;
            int pi = 0;
            int pd=0;
            int pe = 0;

            String pepas = in.next();

            if (pepas.contains("r") && pepas.contains("b")) {//si contengo pepas
                int ci=0;
                int cd=0;
                char letra = 'r';
                pc = pepas.indexOf(letra);
                
                while (pc < cantPepas) {
                    if (letra == 'r') {
                        pi = buscarIzquierda(pepas, 'b', pc);
                        pd = buscarDerecha(pepas, 'b', pc);
                        //falta validacion
                        pe = buscarDerecha(pepas, 'r', pd);
                        letra = 'b';
                    } else {
                        pi = buscarIzquierda(pepas, 'r', pc);
                        pd = buscarDerecha(pepas, 'r', pc);
                        //falta validacion
                        pe = buscarDerecha(pepas, 'b', pd);
                        letra = 'r';
                    }

                    if (pi > pc) {
                        ci = cantPepas - (pi + 1) + pc;
                    } else {
                        ci = pc - (pi + 1);
                    }
                    if (pe < pc) {
                        cd = cantPepas - (pc) + pe;
                    } else {
                        cd = pe - (pc);
                    }
                    if (canMayor < cd + ci) {
                        canMayor = cd + ci;
                    }
                    if(cd+ci==0){
                        canMayor=cantPepas;
                    }
                    System.out.println(ci + " " + cd + " " + canMayor);
                    if(pc < pd)
                    {  pc=pd;
                    }
                    else{
                        pc=cantPepas;
                    }
                }
                out = new java.io.PrintWriter(new java.io.BufferedWriter(new java.io.FileWriter("beads.out")));
                out.print(canMayor);
                out.print("\n");
                out.close();
            } else {
                //Si no contengo pepas
                out = new java.io.PrintWriter(new java.io.BufferedWriter(new java.io.FileWriter("beads.out")));
                out.print(cantPepas);
                out.print("\n");
                out.close();
                System.out.println(cantPepas);
            }

            in.close();
        } catch (FileNotFoundException ex) {
            Logger.getLogger(beads.class.getName()).log(Level.SEVERE, null, ex);
        } catch (IOException ex) {
        }
        if (in != null) {
            in.close();
        }
        if (out != null) {
            out.close();
        }

    }

    /**
     *
     * @param _cadena
     * @param _cBuscar
     * @param _pc
     * @return pepas a la derecha
     */
    public static int buscarDerecha(String _cadena, char _cBuscar, int _pc) {
        int pd = 0;
        if (_cadena.length() == _pc + 1) {
            pd = _cadena.indexOf(_cBuscar);
        } else {
            pd = _cadena.substring(_pc, _cadena.length()).indexOf(_cBuscar);
            if (pd == -1) {
                pd = _cadena.indexOf(_cBuscar);
            } else {
                pd += _pc;
            }
        }
        return pd;
    }

    /**
     *
     * @param _cadena
     * @param _cBuscar
     * @param _pc
     * @return retorna pi
     */
    public static int buscarIzquierda(String _cadena, char _cBuscar, int _pc) {
        if (_pc != 0) {
            _pc = _cadena.substring(0, _pc).lastIndexOf(_cBuscar);
        } else {
            _pc = _cadena.lastIndexOf(_cBuscar);
        }
        if (_pc == -1) {
            _pc = _cadena.lastIndexOf(_cBuscar);
        }
        return _pc;
    }
}
